<?php
include("db_connect.php");
$q = mysql_query("select * FROM tbl_account where type !=1 ");
$userlimit = mysql_num_rows($q);
$fname = "";
$lname ="";
$sStatus = "";
$find[] = ',';
$replace[] = ' ';
 

if(isset($_GET['userlimit'])){
	$userlimit = mysql_real_escape_string(htmlentities(trim( $_GET['userlimit'])));
	
}
if(isset($_GET['fname'])){
	$fname =  mysql_real_escape_string(htmlentities(trim($_GET['fname'])));
	$fname =  str_replace($find, $replace, $fname);
}
if(isset($_GET['lname'])){
	$lname= mysql_real_escape_string(htmlentities(trim( $_GET['lname'])));
	$lname = str_replace($find, $replace, $lname);
}
if(isset($_GET['sStatus'])){
	$sStatus = mysql_real_escape_string(htmlentities(trim( $_GET['sStatus'])));
}
$sql = "SELECT * FROM tbl_account where type !=1 ";

if(!empty($fname) || $fname !="" ){
$sql .= " AND fname like '".$fname."%' ";
}
if(!empty($lname) || $lname !="" ){
$sql .= " AND lname like '".$lname."%' ";
}

if(!empty($sStatus) || $sStatus !="" ){
	$sql .= " AND isaprove = ".$sStatus." ";
}
$sql .= " order by isaprove,lname DESC";
if(!empty($userlimit) || is_numeric($userlimit)){
	
	$sql .= " limit " .$userlimit;
}
$result = mysql_query($sql);

echo "<form id='myform'>";

echo "<table class='tbl_user' border='1' id='tbl_user' width='100%'>

<thead>

<tr>
<th id='tbl_head_color' style=' width:3px; background-color:#ba3e3f; text-align:center;'> <input type='checkbox' name='checkall' onclick='checkedAll();'/></th>
<th id='tbl_head_color' style='width:8px; background-color:#ba3e3f; '>Status</th>
<th id='tbl_head_color' style='width:100px; background-color:#ba3e3f; '>First Name</th>
<th id='tbl_head_color' style='width:100px; background-color:#ba3e3f; '>Last Name</th>
<th id='tbl_head_color' style='width:10px; background-color:#ba3e3f; '>Address</th>
<th id='tbl_head_color' style='width:20px; background-color:#ba3e3f; '>Contacts</th>
<th id='tbl_head_color' style='width:100px; background-color:#ba3e3f; '>Email</th>


</tr>

</thead>";



while($row = mysql_fetch_array($result))

  {

  echo "<tbody >";
	
  
 
  
  if($row['isaprove'] == 1){
	$status="Active";
	echo "<tr class='even' >";
  }
  else if($row['isaprove'] == 2){
	$status="Pending";
	 echo "<tr class='odd' >";
  }
  else{
	$status="Block";
	 echo "<tr class='oddeven' >";
  }
  if($row['type']== 1){
	
  }
  else{
  echo "<td style='text-align:center;' valign='top'><input type='checkbox' class='cd' name='checkbox' value='".$row['id']."'></td>";
  echo "<td valign='top'>" . $status . "</td>";
  echo "<td valign='top'>" . $row['fname'] . "</td>";
  echo "<td valign='top'>" . $row['lname'] . "</td>";
  echo "<td valign='top'>" . str_replace($find, $replace, $row['address']) . "</td>";
  echo "<td valign='top'>" . $row['contacts'] . "</td>";
  echo "<td valign='top'>" . $row['email'] . "</td>";
  }

  
	
  echo "</tr>";

  }

echo "</tbody></table></form>";



mysql_close($conn);

?> 





